package com.qianfeng.wuyang.himalaya.fragment;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.qianfeng.wuyang.himalaya.R;
import com.qianfeng.wuyang.himalaya.adapter.FragmentRbListenerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class RbListenerFragment extends Fragment {
    private ViewPager viewPager;
    private TabLayout tabLayout;
    private List<Fragment> list;


    public RbListenerFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
         View view=inflater.inflate(R.layout.fragment_rb_listener, container, false);
        initViewFragment( view);
        return view;
    }

    private void initViewFragment(View view) {
         viewPager= (ViewPager) view.findViewById(R.id.rb_listenerFragmentViewPager);
         tabLayout= (TabLayout) view.findViewById(R.id.rb_listenerFragmentTabLayout);
         list= new ArrayList<>();
         RbListenerRecommFragment fragment=new RbListenerRecommFragment();
         RbListenerSubscriptionFragment anchorFragment=new RbListenerSubscriptionFragment();
         RbListenerHistoryFragment loadFragment=new RbListenerHistoryFragment();
         list.add(fragment); list.add(anchorFragment);list.add(loadFragment);
         viewPager.setAdapter(new FragmentRbListenerAdapter(getChildFragmentManager(),list));
         tabLayout.setupWithViewPager(viewPager);
    }

}
